
*cd "/Users/eliemurard/Google Drive/ENOE/ENE 2002 wages"
cd "/Users/eliemurard/Google Drive/Mexican Family Survey/distri 2000 wages"
use  ipumscensus2000, clear 

replace mx2000a_incwk=. if mx2000a_incwk==9999999

replace     hrswork1=. if     hrswork1== 998

/* keep only salaried/wage worked */

keep if classwk ==2

	g monthlyinc= mx2000a_incwk*1.09
	
    g hourly_wage = monthlyinc/(4.5*hrswork1 ) 
	
	su hourly_wage  if indgen	==10,d
	
	tostring geolev1, gen(state)
	tostring geolev2, gen(mun)
	
	g  cve_ent =   subinstr(state,"484","",.)
	destring cve_ent , replace force
	
	g  cve_mun =  subinstr( mun, state,"",.)
	destring cve_mun , replace force
	
	
	merge m:1 cve_ent cve_mun using  mxfls_mun
	drop _m
	

	egen munID= group(cve_ent cve_mun)
	* keep  MxFLS rural communities
	
	keep if ( type==3 | type==4 )  & MxFLS==1 
	
	
	save hourly_wage_CENSUS2000 , replace  
	
	
	
		
** LABOR FORCE SURVEY ENOE ***/
	
	
	use 	"/Users/eliemurard/Google Drive/ENOE/ENOE_final07" , clear 

	
	#delimit ; 	
 
 keep  
		id id_h panel* 
		N_ENT D_DIA D_MES year quarter PER
		T_LOC MUN CD_A ENT 
		C_RES_next *migrant C* 
		nb_workerdomestic SEX EDA NAC_DIA  NAC_MES NAC_ANIO L_NAC_C age male  
		rel_head marital_status quest_basico status typesector typework work_lastweek hoursweek days_week ing labincome_month CPI_05 
		P6B2 P6B1 P6C
		;
		#delimit cr
		  

	* RURAL AREA only
		g ruralarea      = T_LOC == 4 | T_LOC == 3
		
		keep if ruralarea  == 1
	
		keep if age >=14 
			
		
* WORK 

	 g  workLW = work_lastweek
	 g  noagr_w=  (workLW==1  )* (typework==1) * (typesector==2)   if  work_lastweek!=. 
	 g  agr_w=  (workLW==1  )* (typework==1) * (typesector==1)   if  work_lastweek!=. 
	 
	foreach v in workLW noagr_w agr_w    {
	
		g `v'_hour = hoursweek * `v' 
		replace  `v'_hour = . if `v' ==1 & ( hoursweek==0 | hoursweek==.) 
	}
	*

	****
	
	replace labincome_month = P6B2 
	
	g hw =  labincome_month  /(4.5*hoursweek) 
	  
	g hw02 = hw*0.85 if year==2005
	replace hw02 = hw*0.82 if year==2006
	replace hw02 = hw*0.78 if year==2007
	
	/* keep only salaried/wage worked */
	keep if  agr_w==1
		
	su hw02   ,d
	
	save hourly_wage_ENOE , replace  
	
	
